﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SharpSphinx.Decoder.Scorer;
using SharpSphinx.Frontend;
using SharpSphinx.Linguist;

namespace SharpSphinx.Decoder.Search
{
    public class Token  : IScoreable
    {
        private static int curCount;
        private static int lastCount; 
        



        private Token Predecessor;

        private float logLanguageScore;
        private float logTotalScore;
        private float logInsertionScore;
        private float logAcousticScore;
        private float logWorkingSore;

        private ISearchState serachState;

        private int location;

        private int frameNumber;
        private IData myData; 

       
        /*Need HashMap*/

        private Dictionary<String, Object> tokenProps; 




        public Token(Token predecessor,
                       ISearchState state,
                       float logTotalScore,
                       float logInsertionScore,
                       float logLanguageScore,
                       int frameNumber)
        {

            this.Predecessor = predecessor;
            this.serachState = state;
            this.logTotalScore = logTotalScore;
            this.logInsertionScore = logInsertionScore;
            this.logLanguageScore = logLanguageScore;
            this.frameNumber = frameNumber;
            this.location = -1;
            curCount++;
        }


        public Token(ISearchState state,int frameNumber)
          : this(null,state,0.0f,0.0f,0.0f,frameNumber)
        {
            
        }


        public Token(Token predecessor, 
                   float logTotalScore, 
                   float logAcousticScore,
                   float logInsertionScore,
                   float logLanguageScore
                    )
            : this(predecessor,null,logTotalScore,logInsertionScore,logLanguageScore,0)
        {
            this.logAcousticScore = logAcousticScore;

        }


        public Token getPredecessor()
        {
            return Predecessor; 
        }


        public override int getFrameNumber()
        {
            return frameNumber; 
        }


        public IData getData()
        {
            return myData; 
        }

        public override float getScore()
        {
            return logTotalScore;
        }


        public override float Calculate(IData feature)
        {

          //  logAcousticScore = ((Sco

            logTotalScore += logAcousticScore; 



            return logTotalScore; 


        }

        public override float NormailzeScore(float maxLogScore)
        {
            logTotalScore -= maxLogScore;
            logAcousticScore -= maxLogScore;
            return logTotalScore; 

        }


        public float getWorkingScore()
        {
            return logWorkingSore; 
        }

        public void setWorkingScore(float logScore) {
            logWorkingSore = logScore; 
        }


        public void setScore(float logScore) { 
         logTotalScore = logScore; 
        }

        public float getLanquageScore() {
            return logLanguageScore;
        }

        public float getInsertionScore()
        {
            return logInsertionScore; 
        }


        public float getAcousticScore()
        {
            return logAcousticScore; 
        }




    }


}
